#!/bin/bash
function showUsage(){
    echo "usages:" 
    echo " ~ : transfer.sh [branchName] [sourceGitAddress] [targetGitAddress]"
}
if [ $# != 3 ] ; then
    showUsage
    exit 0
fi

echo "branchName:    $1"
echo "sourceGitAddr: $2"
echo "targetGitAddr: $3"

git clone -b $1 $2
str=$2
temp=${str##*/}
gitStoreHouseDir=${temp%.git*}
echo "scanning gitStoreHouse: $gitStoreHouseDir"
cd $gitStoreHouseDir
git remote add tempOrigin $3
git push tempOrigin $1
cd ..
rm -rf ./$gitStoreHouseDir

